﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business;
using System.Web.Security;
public partial class admin_View_Site : System.Web.UI.Page {
    Encryption objenc = new Encryption();
    protected void Page_Load(object sender, EventArgs e) {

    }
    /// <summary>
    /// Handles the SelectedIndexChanged event of the GridViewMachine control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    /// <action>go to View_Machine.aspx with machine_id as query string</action>
    protected void GridViewMachine_SelectedIndexChanged(object sender, EventArgs e) {
        string machine_id = GridViewMachine.SelectedDataKey.Value.ToString();
        Server.Transfer("View_Machine.aspx?machine_id=" + machine_id);
    }
    /// <summary>
    /// Handles the Click event of the CreateMachineButton control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    /// <action>go to Create_Machine.aspx with site_id as query string</action>
    protected void CreateMachineButton_Click(object sender, EventArgs e) {
        string site_id = objenc.EncodeUrl(FormViewSites.SelectedValue.ToString());
        Server.Transfer("Create_Machine.aspx?site_id=" + site_id);
    }
    /// <summary>
    /// Handles the DataBound event of the GridViewMachine control.
    /// If there is no Photo specified for the machine
    /// Set the text to "No" otherwise "Yes"
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void GridViewMachine_DataBound(object sender, EventArgs e) {
        foreach (GridViewRow gvr in GridViewMachine.Rows) {
            Label photoLabel = gvr.FindControl("photoLabel") as Label;
            if (photoLabel.Text == "NotAvailable.jpg" || photoLabel.Text == "") {
                photoLabel.Text = "No";
            } else {
                photoLabel.Text = "Yes";
            }
        }
    }
    protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)
    {


        Session.Contents.Remove("UserDetails");
        Session.Abandon();
        Session.Contents.RemoveAll();
        FormsAuthentication.SignOut();
        Response.Redirect("../Default.aspx");
    }

}
